<template>
  <rightArea
    right-title="公文"
    :is-left-title="true"
    :areaHeight="height"
    v-loading="loading"
    @click="titleClickFun"
  >
    <template slot="content">
      <List :data="listData" :listHeight="cListHeight" @itemClick="itemClickFun" />
    </template>
  </rightArea>
</template>

<script>
import rightArea from "@/views/index/Index/common/rightArea";
import List from "@/views/index/Index/components/list";
import { axiosGetNoticeList } from "@/api/portalPublic";
const headerHeight = 40;
export default {
  components: {
    rightArea,
    List
  },
  computed: {
    cListHeight () {
      return this.height - headerHeight;
    }
  },
  props: {
    height: {
      type: [String, Number],
      default: 240
    }
  },
  data () {
    return {
      listData: [],
      loading: true
    };
  },
  methods: {
    getNoticeListFun () {
      axiosGetNoticeList({}).then(res => {
        if (res.status === 200) {
          if (res.data.code === 0) {
            this.listData = res.data.data.records;
            this.loading = false;
          }
        }
      });
    },
    titleClickFun () {
      this.$router.push({ path: "/dashboard/portalPublic/public" });
    },
    itemClickFun (item) {
      console.log(item);
      let url = window.location;
      let hash = url.hash.slice(0, 1);
      window.open(hash + `/dashboard/portalPublic/detail?id=${item.id}`);
    }
  },
  created () {
    this.getNoticeListFun();
  }
};
</script>

<style>
</style>